//
//  CJEmoticonButtton.swift
//  SinaWeibo
//
//  Created by 程建 on 16/10/11.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class CJEmoticonButtton: UIButton {

    var emoticon:CJEmoticon? {

        didSet{
            //设置数据
            let bundle = CJEmoticonTools.sharedEmoticonTools.emoticonBundle
            
            //只有图片表情才有imagePath
            if emoticon!.type == 0 {
                //图片表情
                let image = UIImage(named: emoticon!.imagePath!, in: bundle, compatibleWith: nil)
                setImage(image, for: .normal)
                setTitle(nil, for: .normal)
            }else {
                setTitle(emoticon!.emojiStr, for: .normal)
                //解决图片表情和emoji表情的复用问题
                setImage(nil, for: .normal)
            }

        }
    }
    
}
